package com.user.test.viewModel

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import com.user.test.model.database.SearchResult
import com.user.test.model.database.SearchResultRepository

class RoomViewModel (application: Application) : AndroidViewModel(application) {
    private val repo = SearchResultRepository(application)

    fun getListSearchResult(): LiveData<List<SearchResult>>{
        return repo.getListSearchResults()
    }

    fun insert(searchResult: SearchResult){
        repo.insert(searchResult)
    }

    fun insertList(searchResult: List<SearchResult>){
        repo.insertListSearchResult(searchResult)
    }

    fun update(searchResult: SearchResult){
        repo.update(searchResult)
    }

    fun delete(searchResult: SearchResult){
        repo.delete(searchResult)
    }

    override fun onCleared() {
        super.onCleared()
    }

}